# Maintainer: Jonas Witschel <diabonas@archlinux.org>
# Contributor: Bruno Pagani <archange@archlinux.org>
pkgname=tpm2-abrmd
pkgver=3.0.0
pkgrel=1
pkgdesc='Trusted Platform Module 2.0 Access Broker and Resource Management Daemon'
arch=('loong64' 'x86_64')
url='https://github.com/tpm2-software/tpm2-abrmd'
license=('BSD')
depends=('glib2' 'tpm2-tss' 'libtss2-mu.so' 'libtss2-rc.so' 'libtss2-sys.so' 'libtss2-tctildr.so')
checkdepends=('cmocka' 'iproute2' 'swtpm')
options=('!lto')
source=("$url/releases/download/$pkgver/$pkgname-$pkgver.tar.gz"{,.asc})
sha512sums=('65a39cd0518dfbcbd5835ac6c6628444d412e36471702f2cd1f1077d788330a477778e6403899ea2fa0497b643e5db9ca3e746845492eff78c4c78d8dd8f9e7d'
            'SKIP')
validpgpkeys=('42007E876F248E04A3F2FE25AE4548D043DEC7C3'  # Philip Tricca <philip.b.tricca@intel.com>
              '5B482B8E3E19DA7C978E1D016DE2E9078E1F50C1') # William Roberts (Bill Roberts) <william.c.roberts@intel.com>

build() {
	cd "$pkgname-$pkgver"
	./configure --prefix=/usr \
	            --sbindir=/usr/bin \
	            --with-dbuspolicydir=/usr/share/dbus-1/system.d \
	            $( ((CHECKFUNC)) && echo --enable-unit --enable-integration)
	make
}

check() {
	cd "$pkgname-$pkgver"
	make check
}

package() {
	cd "$pkgname-$pkgver"
	make DESTDIR="$pkgdir" install
	rm -r "$pkgdir/usr/lib/systemd/system-preset"
	install -Dm644 LICENSE -t "$pkgdir/usr/share/licenses/$pkgname"
}
